package com.test.hib;

import java.sql.*;

import java.util.UUID;

import javax.sql.*;

import com.test.Constants;

public class DBTestHib implements Runnable {

	public void run() {
		try {
			System.out.println("Started: " + Thread.currentThread().getName());	
			Department dep;
			
			if (Constants.DO_GUID_INSERTS)
			{
				EmployeeGuidHome empGuidHome = new EmployeeGuidHome();				
				EmployeeGuid empGuid;
				
				for (int i = 0; i < Constants.NO_OF_RECORDS_TO_INSERT_PER_THREAD; i++)
				{
					empGuid = new EmployeeGuid();
					//empGuid.setId("dfgfdg");
					empGuid.setAge((byte) 20);
					empGuid.setFname("John");
					empGuid.setLname("Kumar");
					
					dep = new Department();
					dep.setId("76899c30-87be-11e0-91fc-34bb101b5763");
					empGuid.setDepartment(dep);
					empGuidHome.persist(empGuid);
				}								
			}
			else
			{
				EmployeeAutoHome empAutoHome = new EmployeeAutoHome();
				EmployeeAuto empAuto;
				
				for (int i = 0; i < Constants.NO_OF_RECORDS_TO_INSERT_PER_THREAD; i++)
				{
					empAuto = new EmployeeAuto();
					//empGuid.setId("dfgfdg");
					empAuto.setAge((byte) 20);
					empAuto.setFname("John");
					empAuto.setLname("Kumar");
					
					dep = new Department();
					dep.setId("76899c30-87be-11e0-91fc-34bb101b5763");
					empAuto.setDepartment(dep);
					empAutoHome.persist(empAuto);
				}
			}
		} 
		finally {
			System.out.println("Done: " + Thread.currentThread().getName());
		}

	}

} // end class
